package com.hibase.core.api.controller;

import com.hibase.common.entity.ResponseModel;
import com.hibase.core.api.service.api.HibaseApiService;
import com.hibase.core.web.annotation.HibasePostRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author chenfeng
 * @version 1.0
 * @date 2021/9/30 9:39
 * @des https://gitee.com/cheershi
 */
@Slf4j
@Api(tags = "API接口")
@RestController
@RequestMapping("/api")
public class HibaseApiController {

    @Autowired
    private HibaseApiService apiService;

    @ApiOperation(value = "获取token", httpMethod = "POST")
    @HibasePostRequestMapping(value = "/v1/token")
    public ResponseModel<?> getToken(@RequestBody String requestJson,
                                           @RequestHeader("Authorization") String auth) {
        Map<String,Object> result= apiService.getToken(auth,requestJson);
        return ResponseModel.successMsg(result);
    }
}
